home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / kcl / akcl / akcl1615.lha / h / page.h < prev    next >
C/C++ Source or Header  |  1991-06-09  |  3KB  |  126 lines

  1.  
  2.  
  3. #define MAYBE_DATA_P(pp) ((char *)(pp)>= (char *) DBEGIN)
  4.  
  5. #ifndef DBEGIN
  6. #define DBEGIN 0
  7. #endif
  8.  
  9. #define VALID_DATA_ADDRESS_P(pp) \
  10.   (MAYBE_DATA_P(pp) &&  ((char *)(pp) < heap_end))
  11.  
  12. #ifndef page
  13. #define page(p)    (((int)(((char *)(p))-DBEGIN)>>PAGEWIDTH))
  14. #define    pagetochar(x)    ((char *)(((x) << PAGEWIDTH) + DBEGIN))
  15. #endif
  16.   
  17. #ifdef UNIX
  18. #define CHECK_FOR_INTERRUPT \
  19.    if (interrupt_flag) sigint()
  20. #else
  21. #define CHECK_FOR_INTERRUPT
  22. #endif
  23.  
  24. #ifdef SGC
  25.  
  26. char sgc_type_map[MAXPAGE];
  27. int memory_protect();
  28.  
  29. #define NORMAL_PAGE 0
  30.  
  31. /* writable til next gc at least */
  32. #define SGC_TEMP_WRITABLE  1   
  33.  
  34. /* Contains objects which will be gc'd */
  35. #define SGC_PAGE_FLAG  2       
  36.  
  37. /* keep writable eg malloc's for system call */
  38. #define SGC_PERM_WRITABLE 4    
  39. #define SGC_WRITABLE  (SGC_PERM_WRITABLE | SGC_TEMP_WRITABLE)
  40. #define SGC_PAGE (SGC_TEMP_WRITABLE | SGC_PAGE_FLAG)
  41.  
  42. #define SGC_PAGE_P(p) (sgc_type_map[p] & SGC_PAGE_FLAG)
  43. #define WRITABLE_PAGE_P(p) (sgc_type_map[p] & SGC_WRITABLE)
  44. #define ON_SGC_PAGE(x) (sgc_type_map[page(x)] & SGC_PAGE_FLAG)
  45. #define ON_WRITABLE_PAGE(x) (sgc_type_map[page(x)] & SGC_WRITABLE)
  46.  
  47.  
  48. #define  IF_WRITABLE(x,if_code) do {int xSG= page(x); \
  49.                 if(((xSG & (-MAXPAGE)) ==0) && \
  50.                    (sgc_type_map[xSG] & SGC_WRITABLE)) \
  51.                  {if_code;}} while(0)
  52.  
  53. #define sgc_mark_object(x) IF_WRITABLE(x,if((x)->d.m==0) sgc_mark_object1(x))
  54. /*
  55. #define sgc_mark_object(x) sgc_mark_object1(x)
  56. */
  57. /* When not 0, the free lists in the type manager are freelists
  58.    on SGC_PAGE's, for those types supporting sgc.
  59.    Marking and sweeping is done specially */
  60.    
  61. int sgc_on;
  62.  
  63.  
  64. /* for the S field of the FIRSTWORD */
  65. enum sgc_type { SGC_NORMAL,   /* not allocated since the last sgc */
  66.                 SGC_RECENT    /* allocated since last sgc */
  67.         };
  68.  
  69.  
  70. #define TM_BASE_TYPE_P(i) (((int) (tm_table[i].tm_type)) == i)
  71.  
  72. void perm_writable() ;
  73. void make_writable();   
  74. #define ROUND_DOWN_PAGE_NO(x) ((x) - (x % page_multiple))
  75. #define ROUND_UP_PAGE_NO(x) (page_multiple *(((x)+page_multiple \
  76.                           -1)/page_multiple))
  77.  
  78. /* check if a relblock address is new relblock */
  79. #define SGC_RELBLOCK_P(x)  ((char *)(x) >= rb_start)
  80.  
  81. /* the following assumes that the char s,m fields of first word
  82.    have same length as a short
  83.    (x->d.m || x->d.s) would be an equivalent for our purposes */
  84. struct sgc_firstword {short t; short sm;};
  85. #define SGC_OR_M(x)  (((struct sgc_firstword *)(x))->sm) 
  86.  
  87. #ifndef SIGPROTV
  88. #define SIGPROTV SIGSEGV
  89. #endif
  90.  
  91. #ifndef INSTALL_MPROTECT_HANDLER
  92. #define INSTALL_MPROTECT_HANDLER akcl_signal(SIGPROTV, memprotect_handler)
  93. #endif
  94. extern void memprotect_handler ();
  95.  
  96.         
  97. #else  /* END SGC */
  98. #define sgc_quit()
  99. #define sgc_start()
  100. #define sgc_count_type(x) 0
  101. #endif     
  102.  
  103. extern int sgc_enabled;
  104. #define TM_NUSED(pt) (((pt).tm_npage*(pt).tm_nppage) - (pt).tm_nfree)
  105.  
  106.  
  107. #define F_LINK(x) ((struct freelist *) x)->f_link
  108.  
  109.  
  110.     /* virtual memory pages are this multiple of lisp page size */
  111. #ifndef IN_MAIN  
  112. extern int page_multiple;
  113. #endif       
  114.  
  115.  
  116. /*
  117.     Type map.
  118.  
  119.     enum type type_map[MAXPAGE];
  120. */
  121. char type_map[MAXPAGE];
  122.  
  123.  
  124.  
  125.  
  126.